<?php
class Integral_ruletypeAction extends IntesysAction
{
	//规则分类树
    public function ruletypeTree(){
        if(IS_POST){
			if($this->_post('id')){
				$_POST['pid']=$this->_post('id');
			}elseif($this->_post('pid')){
			}else{
				$_POST['pid']=0;
			}
            $this->dao->getRuletypeTree($pid);
            exit;
        }
        $this->display();
    }
	//添加界面
	public function add(){
		$this->pid=$this->dao->getList();
		parent::add();
	}
	//修改界面
	public function edit(){
		$this->pid=$this->dao->getList();
		parent::edit();	
	}
	//插入数据
	public function insert(){
		$_POST['site_id']=__SITEID__;
		parent::insert();	
	}
	//更新数据
	public function update(){
		if(IS_POST){
			if($this->_param('id')==$this->_param('pid')){
				
			}else{
				parent::update();	
			};
		}	
	}
	//删除数据
	public function delete(){
		if($this->_param('id')){
			$ret=$this->dao->where('pid='.$this->_param('id').' and site_id='.__SITEID__)->find();
			if($ret){
				echo(json_encode(['statu'=>0,'info'=>'错误，该分类下还有子分类，无法删除！']));
			}
			else{parent::delete();}
		}	
	}
	//添加子集
	public function addChild(){
		if($this->_param('id')){
			$this->display();
		}
	}
	//获取某个分类的信息
	public function getInfo(){
		if($this->_param('id')){
			$info=$this->dao->where('id='.$this->_param('id'))->find();
			echo(json_encode(['statu'=>1,'info'=>$info]));	
		}	
	}
}

